3.3.7 基于Proxy和Reflect实现双向数据绑定
var obj = new Proxy({}, {
get: function (target, key, receiver) {
console.log(`proxy get ${key}`)
return Reflect.get(target, key, receiver)
},
set: function (target, key, value, receiver) {
console.log(`proxy set ${key}`)
return Reflect.set(target, key, value, receiver)
}
})
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12